package main

import (
	"context"
	"fmt"
	"log"

	pb "xframe/provider/pdf"

	"google.golang.org/grpc"
)

// protoc --go_out=plugins=grpc:../provider/user user_provider.proto
func main() {
	// java spring boot 暴露的grpc服务接口
	const addr = "127.0.0.1:8002"

	// 连接服务
	conn, err := grpc.Dial(addr, grpc.WithInsecure())
	if err != nil {
		log.Fatalf("远程服务已经关闭 ===> %+v", err)
	}

	// 确保连接最终被关闭
	defer conn.Close()

	client := pb.NewDdfPrintProviderClient(conn)
	reply, err := client.GoPtPdf(context.Background(), &pb.RequestParam{PrinterName: "192.168.10.18", DpfPath: "/Users/walker/Documents/office/花游/2019-猛追湾/丙组基本姿势_基本动作1.pdf"})
	if err != nil {
		log.Fatalf("NewDdfPrintProviderClient 调用错误 ===> %+v", err)
	}

	// 输出结果
	fmt.Println(reply.Code, reply.Msg)
}
